﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CBMS.Interfaces;
using CBMS.Models;
using System.Data.Objects.DataClasses;
using System.Data.Objects; 
using System.Collections;
using CBMS.Objects;
using System.Data.Objects.SqlClient;
using CBMS.Common;
using System.Data.Common;
using System.Data.EntityClient;
using System.Data;
using System.Globalization;

namespace CBMS.Business
{
    public class MasterRepository : BaseEntityRepository<Category>, IMasterRepository
    {
        public MasterRepository()
            : base()
        {

        }
        public IList<ItemDTO> GetAllSubCategroy(string categoryId)
        {
            try
            {
                var query = (from cate in DbContext.SubCategories
                             where cate.category_id == categoryId
                             select new ItemDTO
                             {
                                 Id = cate.subcategory_code,
                                 Name = cate.subcategory_name
                             }).DefaultIfEmpty();
                return query.ToList<ItemDTO>();
            }
            catch
            {
                return new List<ItemDTO>();
            }
        }
    }
}